﻿<%@ Control Language="C#" Inherits="Yuanlin.Business.ZiCaiInfoListControl, Yuanlin.Business" AutoEventWireup="true" %>

<script language="javascript" type="text/javascript">
<!--
function deleteEntitys(){

    var check = document.getElementsByName("entity_id");
	var ifSelect;
	var entityIDs = '';
	for(var i=0;i<check.length;i++){
		if(check[i].checked==true){
		    if(entityIDs == '')
		        entityIDs = check[i].value;
		    else
		        entityIDs = entityIDs + ":" + check[i].value;
			ifSelect = true;
		}
	}
	if(ifSelect == true){
		var delSelect = confirm("确认删除这些资材信息吗？");
		if(delSelect == false){
			return;
		}
		AjaxMethod.DeleteZiCaiInfos('<%=ClientID %>', entityIDs, refreshPage);
	}
	else{
		alert("请选择要删除的记录！");
	}

}

function updateEntitys(){

    var check = document.getElementsByName("entity_id");
	var ifSelect;
	var entityIDs = '';
	for(var i=0;i<check.length;i++){
		if(check[i].checked==true){
		    if(entityIDs == '')
		        entityIDs = check[i].value;
		    else
		        entityIDs = entityIDs + ":" + check[i].value;
			ifSelect = true;
		}
	}
	if(ifSelect == true){
		var delSelect = confirm("确认更新这些资材信息吗？");
		if(delSelect == false){
			return;
		}
		AjaxMethod.UpdateZiCaiInfos('<%=ClientID %>', entityIDs, refreshPage);
	}
	else{
		alert("请选择要更新的记录！");
	}

}

function updateCheckAllChecked(check){
    var checkAll = document.getElementById("CheckAll");
    if(!check.checked){
        checkAll.checked = false;
    }
    else
    {
        var ifAllSelect = true;
        var check = document.getElementsByName("entity_id");
        for(var i=0;i<check.length;i++){
		    if(check[i].checked==false){
			    ifAllSelect = false;
		    }
	    }
	    if(ifAllSelect == true){
            checkAll.checked = true;
	    }
    }
}

function toggleAllCheck(checkAll){
    var check = document.getElementsByName("entity_id");
    for(var i=0;i<check.length;i++){
	    check[i].checked=checkAll.checked;
    }
}

function deleteEntity(entityID){
	var bool = confirm("确认删除该资材信息吗？");
	if(bool == false){
		return;
	}
	AjaxMethod.DeleteZiCaiInfo('<%=ClientID %>', entityID, refreshPage);
}

function updateEntity(entityID){
	var bool = confirm("确认更新该资材信息吗？");
	if(bool == false){
		return;
	}
	AjaxMethod.UpdateZiCaiInfo('<%=ClientID %>', entityID, refreshPage);
}

function refreshPage(res)
{
    window.location.reload();
    var checkAll = document.getElementById("CheckAll");
    checkAll.checked = false;
    toggleAllCheck(checkAll);
}

function CompanyZiCaiInfoAddUrl()
{
    if('<%= kind %>' =='1')
    {
        if('<%= tradeType %>' == '0')
        {
            window.location.href='<%=  SiteUrls.Instance().GetCompanyMachineChuShouAddUrl()%>';
        }
        else if('<%= tradeType %>' == '1')
        {
            window.location.href='<%=  SiteUrls.Instance().GetCompanyMachineQiuGouAddUrl()%>';
        }
    }
    else if('<%= kind %>' =='2')
    {
        if('<%= tradeType %>' == '0')
        {
            window.location.href='<%=  SiteUrls.Instance().GetCompanyFacilityChuShouAddUrl()%>';
        }
        else if('<%= tradeType %>' == '1')
        {
            window.location.href='<%=  SiteUrls.Instance().GetCompanyFacilityQiuGouAddUrl()%>';
        }
    }
    else if('<%= kind %>' =='3')
    {
        if('<%= tradeType %>' == '0')
        {
            window.location.href='<%=  SiteUrls.Instance().GetCompanyAgriculturalChuShouAddUrl()%>';
        }
        else if('<%= tradeType %>' == '1')
        {
            window.location.href='<%=  SiteUrls.Instance().GetCompanyAgriculturalQiuGouAddUrl()%>';
        }
    }
    else if('<%= kind %>' =='4')
    {
        if('<%= tradeType %>' == '0')
        {
            window.location.href='<%=  SiteUrls.Instance().GetCompanyHuaFeiChuShouAddUrl()%>';
        }
        else if('<%= tradeType %>' == '1')
        {
            window.location.href='<%=  SiteUrls.Instance().GetCompanyHuaFeiQiuGouAddUrl()%>';
        }
    }
    else if('<%= kind %>' =='5')
    {
        if('<%= tradeType %>' == '0')
        {
            window.location.href='<%=  SiteUrls.Instance().GetCompanyMashChuShouAddUrl()%>';
        }
        else if('<%= tradeType %>' == '1')
        {
            window.location.href='<%=  SiteUrls.Instance().GetCompanyMashQiuGouAddUrl()%>';
        }
    }
}
function CompanyZiCaiInfoEditUrl(id)
{
    if('<%= kind %>' =='1')
    {
        if('<%= tradeType %>' == '0')
        {
            window.location.href='zicaiinfo/edit.aspx?zicaiinfoid='+id+'&tradetype=0&kind=1';
        }
        else if('<%= tradeType %>' == '1')
        {
            window.location.href='zicaiinfo/edit.aspx?zicaiinfoid='+id+'&tradetype=1&kind=1';
        }
    }
    else if('<%= kind %>' =='2')
    {
        if('<%= tradeType %>' == '0')
        {
            window.location.href='zicaiinfo/edit.aspx?zicaiinfoid='+id+'&tradetype=0&kind=2';
        }
        else if('<%= tradeType %>' == '1')
        {
            window.location.href='zicaiinfo/edit.aspx?zicaiinfoid='+id+'&tradetype=1&kind=2';
        }
    }
    else if('<%= kind %>' =='3')
    {
        if('<%= tradeType %>' == '0')
        {
            window.location.href='zicaiinfo/edit.aspx?zicaiinfoid='+id+'&tradetype=0&kind=3';
        }
        else if('<%= tradeType %>' == '1')
        {
            window.location.href='zicaiinfo/edit.aspx?zicaiinfoid='+id+'&tradetype=1&kind=3';
        }
    }
    else if('<%= kind %>' =='4')
    {
        if('<%= tradeType %>' == '0')
        {
            window.location.href='zicaiinfo/edit.aspx?zicaiinfoid='+id+'&tradetype=0&kind=4';
        }
        else if('<%= tradeType %>' == '1')
        {
            window.location.href='zicaiinfo/edit.aspx?zicaiinfoid='+id+'&tradetype=1&kind=4';
        }
    }
    else if('<%= kind %>' =='5')
    {
        if('<%= tradeType %>' == '0')
        {
            window.location.href='zicaiinfo/edit.aspx?zicaiinfoid='+id+'&tradetype=0&kind=5';
        }
        else if('<%= tradeType %>' == '1')
        {
            window.location.href='zicaiinfo/edit.aspx?zicaiinfoid='+id+'&tradetype=1&kind=5';
        }
    }
}
//-->
</script>

<fieldset>
	<legend><asp:Literal ID="zicaiInfoLiteral" runat="server"></asp:Literal></legend>	
			
    <asp:Repeater id="list" runat="server">
        <HeaderTemplate>
            <table border="0" cellpadding="0" cellspacing="0" class="AdminTable">
	            <thead>
		            <tr>
			            <th class="NumCol"><input type="checkbox" onclick="toggleAllCheck(this)" id="CheckAll" title="全选/取消全选" /></th>
			            <th class="TitleCol">名称</th>
			            <th>类别</th>
			            <th class="BigActionCol">更新日期</th>
			            <th class="ActionCol">操作</th>
		            </tr>
	            </thead>
	            <tbody>
        </HeaderTemplate>
        <ItemTemplate>
            <tr>
			    <td class="NumCol">
				    <input type="checkbox" onclick="updateCheckAllChecked(this)" name="entity_id" id="entity_id" value="<%# ((ZiCaiInfo)Container.DataItem).EntityId.Value %>"/>
			    </td>
			    <td class="TitleCol">
				    <a href="javascript:CompanyZiCaiInfoEditUrl(<%# ((ZiCaiInfo)Container.DataItem).EntityId.Value %>)">
					    <%# DataBinder.Eval(Container.DataItem, "Title")%>
				    </a>
			    </td>
			    <td>
			        <%# ((ZiCaiInfo)Container.DataItem).SecondCategoryText.Value%>
			    </td>
			    <td class="BigActionCol">
			        <%# ((ZiCaiInfo)Container.DataItem).UpdateDate.Value.ToShortDateString()%>
			    </td>
			    <td class="ActionCol">
			        <!-- INSERT POSITION -->
					<a class="" href="javascript:void(0);" onclick="deleteEntity(<%# ((ZiCaiInfo)Container.DataItem).EntityId.Value %>)" alt="删除" title="删除"><span>删除</span></a>
					<a class="" href="javascript:void(0);" onclick="updateEntity(<%# ((ZiCaiInfo)Container.DataItem).EntityId.Value %>)" alt="更新发布日期" title="更新发布日期"><span>更新</span></a>
			    </td>
		    </tr>
        </ItemTemplate>
        <FooterTemplate>
			    </tbody>
	        </table>
	        <div class="FormRow ButtonRow">
		        <input type="button" class="Button" onclick="deleteEntitys()" value="删除选择"/>
		        <font color="red"></font>&nbsp;&nbsp;&nbsp;&nbsp;
		        <input type="button" class="Button" onclick="updateEntitys()" value="更新选择" title="更新发布日期"/>
		        <font color="red"></font>&nbsp;&nbsp;&nbsp;&nbsp;
		        <input type="button" class="Button" onclick="CompanyZiCaiInfoAddUrl()" value="添加"/>
	        </div>
        </FooterTemplate>
    </asp:Repeater>
    <div class="PagingWrapper">
        <asp:Panel  Runat="server" align="right" CssClass="CommonPagingArea">
            <nwap:CurrentPage Cssclass="columnText" id="currentPage" runat="server" />
            <nwap:Pager id="pager" runat="server" PageSize="20" />
        </asp:Panel>
    </div>
</fieldset>